from django.db import models


# Create your models here.

class MemberInfo(models.Model):
    IS_ACTIVE = (
        (0, '未激活'),
        (1, '已激活')
    )
    nickname = models.CharField(max_length=20, unique=False, null=False, verbose_name='账户昵称')
    login_password = models.CharField(max_length=68, unique=False, null=False, verbose_name='登录密码')
    wallet_password = models.CharField(max_length=68, unique=False, null=False, verbose_name='钱包密码')
    phone = models.CharField(max_length=11, unique=True, null=False, verbose_name='账户手机')
    email = models.CharField(max_length=128, unique=True, null=True, verbose_name='邮箱地址')
    qq = models.CharField(max_length=20, unique=True, null=True, verbose_name='QQ')
    salt = models.CharField(max_length=68, unique=False, null=False, verbose_name='加密盐值')
    is_active = models.SmallIntegerField(choices=IS_ACTIVE, unique=False, null=False, default=1, verbose_name='激活状态')
    last_login_ip = models.CharField(max_length=20, unique=False, null=False, verbose_name='最近登录IP')
    created_time = models.DateTimeField(unique=False, null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(unique=False, null=False, verbose_name='更新时间')
    last_login_time = models.DateTimeField(unique=False, null=True, verbose_name='最近登录时间')

    class Meta:
        db_table = 'member_info'
        verbose_name = '账户信息'
        verbose_name_plural = verbose_name


class BusinessInfo(models.Model):
    business_code = models.IntegerField(unique=True, null=False, verbose_name='商户编号')
    business_name = models.CharField(max_length=20, unique=False, null=True, verbose_name='商户名称')
    business_website = models.TextField(unique=False, null=True, verbose_name='商户网站链接')
    business_notice = models.TextField(unique=False, null=True, verbose_name='商户公告')
    created_time = models.DateTimeField(unique=False, null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(unique=False, null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'business_info'
        verbose_name = '商户信息'
        verbose_name_plural = verbose_name


class MemberBusiness(models.Model):
    ROLE = (
        (1, '商家'),
        (2, '代理')
    )
    IS_ACTIVE = (
        (0, '未激活'),
        (1, '已激活')
    )
    phone = models.CharField(max_length=11, unique=False, null=False, verbose_name='账户手机')
    business_code = models.IntegerField(unique=False, null=False, verbose_name='商户编号')
    business_role = models.SmallIntegerField(choices=ROLE, unique=False, null=False, verbose_name='账户角色')
    qq = models.CharField(max_length=20, unique=False, null=True, verbose_name='QQ')
    web_link_mark = models.CharField(max_length=48, unique=True, null=False, verbose_name='链接标识')
    is_active = models.SmallIntegerField(choices=IS_ACTIVE, unique=False, null=False, default=1, verbose_name='激活状态')
    created_time = models.DateTimeField(unique=False, null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(unique=False, null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'member_business'
        verbose_name = '商户账户关联信息'
        verbose_name_plural = verbose_name


class BlockAgent(models.Model):
    phone = models.CharField(max_length=11, unique=False, null=False, verbose_name='账户手机')
    business_code = models.IntegerField(unique=False, null=False, verbose_name='商户编号')
    block_code = models.CharField(max_length=68, unique=False, null=False, verbose_name='区组编号')
    distribution_scale = models.DecimalField(max_digits=10, decimal_places=2, unique=False, null=False, default=0.00, verbose_name='分销比例')
    created_time = models.DateTimeField(unique=False, null=False, verbose_name='创建时间')
    updated_time = models.DateTimeField(unique=False, null=False, verbose_name='更新时间')

    class Meta:
        db_table = 'block_agent'
        verbose_name = '区组-代理关系'
        verbose_name_plural = verbose_name
